package oop.day05;

public class RefDemo03 {
    public static void main(String[] args) {
        Animal dog = new Dog();// dog 对象，定义为父类的 animal类型
        System.out.println(dog instanceof Dog);
        if (dog instanceof Dog) {
            Dog dog1= (Dog) dog;// 该对象 就是dog 类型
        }

        System.out.println(dog instanceof Swim);
        Swim dog2= (Swim) dog;// 该对象 实现了该接口

        Animal fish = new Fish();
        System.out.println(fish instanceof Fish);
        Fish fish1 = (Fish) fish;// 该对象 就是fish 类型
        System.out.println(fish instanceof Swim);
        Swim fish2 = (Swim) fish;// 该对象 实现了该接口

        Animal chick = new Chick();
        System.out.println(chick instanceof Chick);
        Chick chick1 = (Chick) chick;// 该对象 就是fish 类型
        System.out.println(chick instanceof Swim);
        if (chick instanceof Swim) {
            Swim chick2 = (Swim) chick;
        }

    }
}
